// 统一管理用户相关的接口
// import request from '@/utils/http/request'
import request from '@/utils/http/index';

import { GetUserInfoModel, LoginParams, LoginResultModel } from './model/userModel';

/**
 * api地址
 */
enum Api {
    Register = '/system/register',
    Login = '/system/login',
    // Login = '/login',
    Logout = '/system/logout',

    GetUserInfo = '/system/getUserInfo',
    // GetUserInfo = '/getUserInfo',
    GetPermCode = '/getPermCode',
    ResetPassword = '/system/resetPassword',
    SendeVerificationCode = '/system/sendVerificationCode',

}

/**
 * @description: user login api
 */
export const loginApi = (data: LoginParams) => {
  // return request.post<any,LoginResultModel>(Api.Login, params);
  return request.post<LoginResultModel>({ url: Api.Login, data });
}

export const  registerApi = (data: LoginParams) => {
  // return request.post<any,LoginResultModel>(Api.Login, params);
  return request.post<LoginResultModel>({ url: Api.Register, data });
}

/**
 * @description: getUserInfo
 */
export const getUserInfo = () => {
  // return request.get<any,GetUserInfoModel>(Api.GetUserInfo);
  return request.get<GetUserInfoModel>({url: Api.GetUserInfo});
}

export const getPermCode = () => {
  // return request.get<any,string[]>(Api.GetPermCode);
  return request.get<GetUserInfoModel>({ url: Api.GetUserInfo});
}

export const doLogout = () => {
  return request.get({ url: Api.Logout});
}


export const resetPasswordApi = (data: LoginParams) => {
  return request.post<LoginResultModel>({ url: Api.ResetPassword, data });
}

export const sendVerificationCodeApi = (data: LoginParams) => {
  return request.post<LoginResultModel>({ url: Api.SendeVerificationCode, data });
}